package com.rd.sys.common.fileexport.inter.impl;

import baseproj.common.exception.BaseServiceException;
import com.rd.sys.common.fileexport.inter.ExportOperator;
import com.rd.sys.dto.analysis.statistic.StatisticExportDto;
import com.rd.sys.dto.client.store.EventModel;
import com.rd.sys.dto.commmon.base.BaseDto;
import com.rd.sys.service.analysis.statistic.StatisticService;

import java.util.ArrayList;
import java.util.List;

/**
 * <br/>
 *
 * @author admin
 * @title 》EventRawDataExport
 * @data 2019-12-30 14:03
 * @since 1.0.1
 */
public class EventRawDataExport extends ExportOperator {

    @Override
    public List<String> operation(BaseDto dto, String splitSign) throws BaseServiceException, Exception {
        StatisticService statisticService = (StatisticService) getService("statisticServiceImpl");

        StatisticExportDto exportDto = (StatisticExportDto) dto;

        List<EventModel> statDataList = statisticService.queryEventDataList(exportDto.getUserCode(),
                exportDto.getProjectCode(), exportDto.getSchemeCode(), exportDto.getResultCode(), exportDto.getPage());

        List<String> contentList = new ArrayList<String>();

        StringBuilder content = new StringBuilder();
        for (EventModel resultData : statDataList) {
            content.append(resultData.getNum()).append(splitSign);
            content.append(resultData.getResultName()).append(splitSign);
            content.append(resultData.getMaterialName()).append(splitSign);
            content.append(resultData.getValue()).append(splitSign);
            content.append(" "+resultData.getEventTimes()+" ").append(splitSign);
            content.append(resultData.getIntervalTime()).append(splitSign);
            content.append(resultData.getCoordinate()).append(splitSign);
            contentList.add(content.toString());
            content.delete(0, content.length());
        }
        return contentList;
    }
}
